package it.polimi.traveldream.persistence;

import it.polimi.traveldream.dtos.DefaultPackageDTO;

import java.io.Serializable;

import javax.persistence.*;

import java.util.Date;
import java.util.List;

/**
 * The persistent class for the PacchettoPredefinito database table.
 * 
 */
@Entity(name = "DEFAULT_PACKAGE")
@NamedQueries({
		@NamedQuery(name = DefaultPackage.FIND_ALL, query = "SELECT p FROM DEFAULT_PACKAGE p"),
		@NamedQuery(name = DefaultPackage.FIND_BY_NAME, query = "SELECT p FROM DEFAULT_PACKAGE p WHERE p.name = :name"),
		@NamedQuery(name = DefaultPackage.FIND_BY_ID, query = "SELECT p FROM DEFAULT_PACKAGE p WHERE p.id = :id") })
public class DefaultPackage implements Serializable {

	private static final long serialVersionUID = 1L;

	
	public static final String FIND_ALL = "DefaultPackage.findAll";
	
	public static final String FIND_BY_NAME = "DefaultPackage.findByName";
	
	public static final String FIND_BY_ID = "DefaultPackage.findById";

	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;

	@Temporal(TemporalType.DATE)
	private Date endDate;

	@Temporal(TemporalType.DATE)
	private Date startDate;

	@Lob
	private String description;

	private String name;

	@ManyToMany
	@JoinTable(name = "INCLUDES", joinColumns = { @JoinColumn(name = "package_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "product_id", referencedColumnName = "productId") })
	private List<Product> products;

	public DefaultPackage() {
	}

	/**
	 * @param defaultPackageDTO
	 */
	public DefaultPackage(DefaultPackageDTO defaultPackageDTO) {

		this.name = defaultPackageDTO.getName();
		this.description = defaultPackageDTO.getDescription();
		this.startDate = defaultPackageDTO.getStartDate();
		this.endDate = defaultPackageDTO.getEndDate();

	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Product> getProducts() {
		return products;
	}

	public void setProducts(List<Product> products) {
		this.products = products;
	}



}